<?php
namespace app\common\model;

class PlatformRecharge extends Base
{
    protected $table = 'platform_recharges';

    protected static function init()
    {

    }

    public function getCreateTimeLabelAttr($value, $data)
    {
        if (empty($data['create_time'])) {

            return '';
        }

        return date('Y-m-d H:i:s', $data['create_time']);
    }

    public function getStatusTimeLabelAttr($value, $data)
    {
        if (empty($data['status_time'])) {

            return '';
        }

        return date('Y-m-d H:i:s', $data['status_time']);
    }

    public function getPlatformIdLabelAttr($value, $data)
    {
        $platform = Platform::get(array('id' => $data['platform_id']));

        if (empty($platform)) {
            return '未知';
        }

        return $platform['name'];
    }

    public function getPlatformTypeLabelAttr($value, $data)
    {
        if ($data['platform_type'] == 1) {
           return '独享';
        }

        if ($data['platform_type'] == 2) {
            return '共享';
        }

        return '未知';
    }

    public function getStatusArrAttr($value, $data)
    {
        switch ($data['status']) {
            case 1:
                $result['status_label'] = '已通过';
                $result['status_class'] = 'layui-btn-default';
                break;
            case -1:
                $result['status_label'] = '未通过';
                $result['status_class'] = 'layui-btn-danger';
                break;
            default:
                $result['status_label'] = '等待审核';
                $result['status_class'] = 'layui-btn-primary';
                break;
        }

        return $result;
    }

    public function getRechargeImgLabelAttr($value, $data)
    {
        if (!isset($data['recharge_img']) || empty($data['recharge_img'])) {
            return array();
        }

        return explode(';', $data['recharge_img']);
    }



}